﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: FZH
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;
using FriendStar.Code;
using FriendStar.Domain.Entity.BOM;
using FriendStar.Domain.IRepository.BOM;
using FriendStar.Repository.BOM;

namespace FriendStar.Application.BOM
{
    /// <summary>
	/// 数据视图 V_PLM_DJ_TREEWGGXJG 对应的数据应用功能类。
	/// </summary>
	public class V_PLM_DJ_TREEWGGXJGApp
    {       
        private string UseUnit = Configs.GetValue("UseUnit");  

        private IV_PLM_DJ_TREEWGGXJGRepository service = new V_PLM_DJ_TREEWGGXJGRepository();

        public List<V_PLM_DJ_TREEWGGXJGEntity> GetList(Pagination pagination, string keyword)
        {
            var expression = ExtLinq.True<V_PLM_DJ_TREEWGGXJGEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.TH.Contains(keyword));
            }
            return service.FindList(expression, pagination);
        }

        public V_PLM_DJ_TREEWGGXJGEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }

        public List<V_PLM_DJ_TREEWGGXJGEntity> GetMultiQueryList()
        {
            string sql = "select fdh,CCBZ,FSign,TH,MC,BB,BC,WZH,SL,LXD,LXDRQ,StartDate,StopDdate,ZDH01,WZH01,SL01,LXD01,LXDRQ01,StopDdate01,ZDH02,WZH02,SL02,LXD02,LXDRQ02,StopDdate02,ZDH03,WZH03,SL03,LXD03,LXDRQ03,StopDdate03,ZDH04,WZH04,SL04,LXD04,LXDRQ04,StopDdate04,ZDH05,WZH05,SL05,LXD05,LXDRQ05,StopDdate05,ZDH06,WZH06,SL06,LXD06,LXDRQ06,StopDdate06,ZDH07,WZH07,SL07,LXD07,LXDRQ07,StopDdate07,ZDH08,WZH08,SL08,LXD08,LXDRQ08,StopDdate08,ZDH09,WZH09,SL09,LXD09,LXDRQ09,StopDdate09,ZDH10,WZH10,SL10,LXD10,LXDRQ10,StopDdate10,ZDH11,WZH11,SL11,LXD11,LXDRQ11,StopDdate11,ZDH12,WZH12,SL12,LXD12,LXDRQ12,StopDdate12,ZDH13,WZH13,SL13,LXD13,LXDRQ13,StopDdate13,ZDH14,WZH14,SL14,LXD14,LXDRQ14,StopDdate14 from  V_PLM_DJ_TREEWGGXJG  where UseUnit ='25000' order by  ZDH01,ZDH02,ZDH03,ZDH04,ZDH05,ZDH06,ZDH07,ZDH08,ZDH09,ZDH10,ZDH11,ZDH12,ZDH13,ZDH14";
            return service.FindList(sql);
        }

        public int MultiQueryCalculate(string id, string th, string type)
        {
            string sql = string.Format("EXEC Pro_Plm_DJCX  '{0}','{1}','{2}','{3}','{4}'", UseUnit, type, th, id, OperatorProvider.Provider.GetCurrent().UserName);
            return service.ExecSql(sql);
        }
    }
}